package likou;

import java.util.HashMap;
import java.util.Map;

/**
 * @author: 唐小尊
 * @email: 1171702529@qq.com
 * @cate: 2021/06/24 08:05
 */
public class _149 {
    public static void main(String[] args) {
        System.out.println(maxPoints(new int[][]{{2,3},{3,3},{-5,3}}));
    }
    public static int maxPoints(int[][] points) {
        int res = 0;
        for(int i=0;i<points.length-1;i++){
            Map<Double,Integer> map = new HashMap<>();
            for(int j=i+1;j<points.length;j++){
                double _x = (points[i][0]-points[j][0]);
                double _y = (points[i][1]-points[j][1]);
                //y/x
                Double key;
                if(_x==0){
                    map.merge(null,1,Integer::sum);
                    key = null;
                }else if (_y==0){
                    map.merge(_y,1,Integer::sum);
                    key = _y;
                }else {
                    map.merge(_y/_x,1,Integer::sum);
                    key = _y/_x;

                }
                res = Math.max(res, map.get(key));
            }
        }
        return res+1;
    }
}
